package com.jwgf.itemviewdelegates;

import com.jwgf.adapter.ItemViewDelegate;
import com.jwgf.adapter.MultiItemTypeAdapter;
import com.jwgf.adapter.RecyclerViewHolder;
import com.jwgf.smarowindingmachine_unity.R;

public class StatisticButtonDelegate implements ItemViewDelegate {
    private MultiItemTypeAdapter<Object> adapter;

    public StatisticButtonDelegate(MultiItemTypeAdapter<Object> adapter) {
        this.adapter = adapter;
    }

    @Override
    public int getItemViewLayoutId() {
        return R.layout.statistic_button;
    }

    @Override
    public boolean isForViewType(Object item, int position) {
        return item instanceof StatisticButtonAttr;
    }

    @Override
    public void bindView(RecyclerViewHolder holder, Object o, int position) {
        StatisticButtonAttr attr = (StatisticButtonAttr) o;
        holder.setText(R.id.name, attr.getName());
        holder.setText(R.id.value, attr.getValue());
        holder.setVisible(R.id.statistic_button, attr.isVisible());
        holder.setSelected(R.id.statistic_button, attr.isSelected());
    }
}
